package org.deltaset.meta.internal;

import java.util.List;
import java.util.Map;
import org.deltaset.meta.MetaAction;
import org.deltaset.meta.MetaField;

/**
 *
 * @author dmakariev
 */
class MetaClass {

    private final Class entityClass;
    private final Map<String, List<MetaField>> orderedFieldsMap;
    private final List<MetaField> allMetaFields;
    /////
    private final MetaAction findByIdAction;
    private final MetaAction defaultFinder;
    private final Map<ActionClassifierType, List<MetaAction>> actionMap;
    private final List<MetaAction> allMetaActions;

    MetaClass(Class entityClass,
            Map<String, List<MetaField>> orderedFieldsMap,
            List<MetaField> allMetaFields,
            MetaAction findByIdAction,
            MetaAction defaultFinder,
            Map<ActionClassifierType, List<MetaAction>> actionMap,
            List<MetaAction> allMetaActions) {
        this.entityClass = entityClass;
        this.orderedFieldsMap = orderedFieldsMap;
        this.allMetaFields = allMetaFields;
        this.findByIdAction = findByIdAction;
        this.defaultFinder = defaultFinder;

        this.actionMap = actionMap;
        this.allMetaActions = allMetaActions;
    }

    MetaAction getFindByIdAction() {
        return findByIdAction;
    }

    MetaAction getDefaultFinder() {
        return defaultFinder;
    }

    List<MetaAction> getGroup(ActionClassifierType groupType) {
        return actionMap.get(groupType);
    }

    List<MetaAction> getAllMetaActions() {
        return allMetaActions;
    }

    public List<MetaField> getAllMetaFields() {
        return allMetaFields;
    }

    Class getEntityClass() {
        return entityClass;
    }

    //TODO: find why there is javax.el.BeanELResolver can not access a member ... exception when Collections.unmodifiableList is used
    List<MetaField> orderedFieldsFor(final String viewName) {
        return orderedFieldsMap.get(viewName);
    }
}
